package com.yanqu.road.server.gameplayer.module.activity.strongholdwar;

import com.yanqu.road.entity.activity.*;
import com.yanqu.road.entity.config.goods.GoodsInfo;
import com.yanqu.road.entity.enums.eItemId;
import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.entity.enums.eMailType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.logic.helper.RandomWeightConfigHelper;
import com.yanqu.road.server.manger.union.CrossUnionMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.activity.StrongholdActivityProto;
import com.yanqu.road.pb.commonactivity.CommonActivityProto;
import com.yanqu.road.pb.cross.activity.CrossActivityProto;
import com.yanqu.road.pb.crossunion.activity.CrossUnionActivityRankDataProto;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.banquet.BanquetModule;
import com.yanqu.road.server.gameplayer.module.base.GeneralModule;
import com.yanqu.road.server.gameplayer.module.player.BagModule;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.gameplayer.module.player.DecorationModule;
import com.yanqu.road.server.logic.activity.stronghold.StrongholdActivityData;
import com.yanqu.road.server.logic.activity.stronghold.condition.BaseStrongholdActivityCondition;
import com.yanqu.road.server.logic.mail.MailManager;
import com.yanqu.road.server.manger.MultipleLanguageMgr;
import com.yanqu.road.server.manger.ServerLanguageMgr;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.orewar.OreWarActivityMgr;
import com.yanqu.road.server.manger.activity.orewar.OreWarActivityRankMgr;
import com.yanqu.road.server.manger.activity.strongholdwar.StrongholdActivityMgr;
import com.yanqu.road.server.manger.activity.strongholdwar.StrongholdActivityRankMgr;
import com.yanqu.road.server.manger.config.GoodsMgr;
import com.yanqu.road.server.manger.log.LogMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.system.CommonMgr;
import com.yanqu.road.server.manger.union.UnionActivityMgr;
import com.yanqu.road.server.pb.StrongholdActivityPb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.math.BigInteger;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class StrongholdActivityModule extends GeneralModule {

    private Map<Integer, Map<Integer, StrongholdActivityData>> activityDataMap;

    public StrongholdActivityModule(GamePlayer player) {
        super(player);
    }

    @Override
    public boolean afterLoadData() {
        return false;
    }

    @Override
    public boolean saveData() {
        return true;
    }

    @Override
    public boolean loadData() {
        activityDataMap = new ConcurrentHashMap<>();
        ActivityInfo activityInfo = StrongholdActivityMgr.getOpenActivityInfo();
        if (activityInfo != null) {
            Map<Integer, List<UserActivityConditionData>> userActivityConditionDataMap = StrongholdActivityMgr.getUserActivityConditionDataMap(getUserId(), activityInfo.getActivityId());
            if (null != userActivityConditionDataMap) {
                for (Map.Entry<Integer, List<UserActivityConditionData>> dataEntry : userActivityConditionDataMap.entrySet()) {
                    addActivity(activityInfo, dataEntry.getValue(), dataEntry.getKey(), false);
                }
            }
            addNewActivity();
        }
        return true;
    }

    @Override
    public void loginSendMsg() {

    }

    @Override
    public void afterLogin() {
        syncActivity();
      /*  ActivityInfo activityInfo = StrongholdActivityMgr.getActivityInfo();

        if (!ActivityMgr.activityInShowTime(activityInfo) || StrongholdActivityMgr.activityInCanRewardPeriod()) {
            //如果活动过期
            returnDonateItem();
            returnMammonItem();
        }
        if (StrongholdActivityMgr.activityInCanRewardPeriod()) {
            returnHuangJiaGongpin();
        }
        if (activityInfo == null) {
            returnTradeItem();
            returnShovelItem();
        }*/
    }

    private void returnHuangJiaGongpin() {
        List<Integer> needRemoveItemList = new ArrayList<>();
        needRemoveItemList.add(eItemId.STRONGHOLD_GONGPIN.getValue());
        returnItem(needRemoveItemList, MailManager.STRONGHOLD_RETURN_ITEM_TITLE, MailManager.STRONGHOLD_RETURN_ITEM_CONTENT, 1, true);
    }

    private void returnShovelItem() {
        List<Integer> needRemoveItemList = new ArrayList<>();
        needRemoveItemList.add(eItemId.STRONGHOLD_SHOVEL_ITEM.getValue());
        returnItem(needRemoveItemList, "", "", 4, false);
    }

    private void returnDonateItem() {
        List<Integer> needRemoveItemList = new ArrayList<>();
        needRemoveItemList.add(eItemId.STRONGHOLD_CHINA.getValue());
        needRemoveItemList.add(eItemId.STRONGHOLD_TEA.getValue());
        needRemoveItemList.add(eItemId.STRONGHOLD_SILK.getValue());
        returnItem(needRemoveItemList, MailManager.STRONGHOLD_RETURN_ITEM_TITLE, MailManager.STRONGHOLD_RETURN_ITEM_CONTENT, 1, true);
    }

    private void returnMammonItem() {
        List<Integer> needRemoveItemList = new ArrayList<>();
        //    needRemoveItemList.add(eItemId.STRONGHOLD_MAMMON_YIZHIQIANJIN.getValue());
        needRemoveItemList.add(eItemId.STRONGHOLD_MAMMON_QIANKUNYIZHI.getValue());
        returnItem(needRemoveItemList, MailManager.STRONGHOLD_RETURN_MAMMON_ITEM_TITLE, MailManager.STRONGHOLD_RETURN_MAMMON_ITEM_CONTENT, 2, true);
    }

    private void returnTradeItem() {
        List<Integer> needRemoveItemList = new ArrayList<>();
        needRemoveItemList.add(eItemId.STRONGHOLD_TRADE_ITEM_1.getValue());
        needRemoveItemList.add(eItemId.STRONGHOLD_TRADE_ITEM_2.getValue());
        needRemoveItemList.add(eItemId.STRONGHOLD_TRADE_ITEM_3.getValue());
        needRemoveItemList.add(eItemId.STRONGHOLD_TRADE_ITEM_4.getValue());
        needRemoveItemList.add(eItemId.STRONGHOLD_TRADE_ITEM_5.getValue());
        needRemoveItemList.add(eItemId.STRONGHOLD_TRADE_ITEM_6.getValue());
        needRemoveItemList.add(eItemId.STRONGHOLD_TRADE_ITEM_7.getValue());
        needRemoveItemList.add(eItemId.STRONGHOLD_TRADE_ITEM_8.getValue());
        returnItem(needRemoveItemList, "", "", 3, false);
    }

    private void returnItem(List<Integer> needRemoveItemList, String titleKey, String contentKey, int type, boolean needSendMail) {
        // 1是道具捐赠  2是财神助力
        Property reward = new Property();
        Map<String, Long> returnItemMap = new HashMap<>();
        for (Integer itemId : needRemoveItemList) {
            UserBagItem bagItem = player.getModule(BagModule.class).getUserBagItem(itemId);
            if (bagItem != null && bagItem.getNum() > 0) {
                long num = bagItem.getNum();
                player.getModule(CurrencyModule.class).removeCurrency(new Property(bagItem.getGoodsId(), BigInteger.valueOf(bagItem.getNum())), eLogMoneyType.Stronghold, eLogMoneyType.StrongholdItemRemove);
                log.info("回收道具 {}， 数量： {}", bagItem.getGoodsId(), num);
                GoodsInfo goodsInfo = CommonMgr.getGoodsInfo(itemId);
                if (type == 1) {
                    for (long i = 0; i < num; i++) {
                        String extendParam = goodsInfo.getExtendParam();
                        Property property = RandomWeightConfigHelper.getRandomProperty(extendParam);
                        reward.addProperty(property);
                    }
                } else if (type == 2) {
                    for (int i = 0; i < num; i++) {
                        Property useReward = StrongholdActivityMgr.getMammonUseReward(itemId);
                        reward.addProperty(useReward);
                    }
                }
                returnItemMap.put(goodsInfo.getGoodsName(), num);
            }
        }
        if (returnItemMap.size() > 0 && needSendMail) {
            String language = UserMgr.getLanguage(player.getUserId());
            StringBuilder returnStr = new StringBuilder();
            for (Map.Entry<String, Long> entry : returnItemMap.entrySet()) {
                String key = entry.getKey();
                Long value = entry.getValue();
                returnStr.append(ServerLanguageMgr.getContent(key, language)).append("X").append(value).append(", ");
            }
            returnStr.deleteCharAt(returnStr.length() - 1);
            String title = MultipleLanguageMgr.getContent(titleKey, language);
            String content = StringUtils.format(MultipleLanguageMgr.getContent(contentKey, language),
                    returnStr.toString());
            MailManager.sendMail(player.getUserId(), eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(reward), content, title);
        }
    }

    public void syncActivity() {
        ActivityInfo activityInfo = StrongholdActivityMgr.getActivityInfo();

        if (activityInfo != null) {
            if (ActivityMgr.activityInShowTime(activityInfo)) {
                //每一次下发前 都校验下是否添加了新活动
                addNewActivity();
                Map<Integer, StrongholdActivityData> tempMap = activityDataMap.get(activityInfo.getActivityId());
                player.sendPacket(ClientProtocol.U_STRONGHOLD_WAR_CONFIG,
                        StrongholdActivityPb.getStrongholdActivityMsg(activityInfo, StrongholdActivityMgr.getDesertConfigMap(), StrongholdActivityMgr.getDonateConfigMap(),
                                StrongholdActivityMgr.getConditionInfoMap(), StrongholdActivityMgr.getParamConfigMap(), StrongholdActivityMgr.getTimeConfigMap(),
                                StrongholdActivityMgr.getTradeConfigMap(), StrongholdActivityMgr.getWildConfigMap(), StrongholdActivityMgr.getMallInfoMap(), tempMap, player.getLanguage()));
            }
        } else {
            StrongholdActivityProto.SyncStrongholaActivityMsg.Builder msg = StrongholdActivityProto.SyncStrongholaActivityMsg.newBuilder();
            player.sendPacket(ClientProtocol.U_STRONGHOLD_WAR_CONFIG, msg);
        }


    }

    public void addNewActivity() {
        ActivityInfo activityInfo = StrongholdActivityMgr.getActivityInfo();
        if (activityInfo != null) {
            synchronized (this) {
                Map<Integer, List<ActivityConditionInfo>> dataMap = StrongholdActivityMgr.getActivityConditionInfoMap(activityInfo.getActivityId());
                if (null != dataMap) {
                    for (int type : dataMap.keySet()) {
                        addActivity(activityInfo, new ArrayList<>(), type, true);
                    }
                }
                Map<Integer, StrongholdActivityData> tempActivityDataMap = getActivityDataMap(activityInfo.getActivityId());
                if (null != tempActivityDataMap) {
                    for (StrongholdActivityData activityData : tempActivityDataMap.values()) {
                        for (BaseStrongholdActivityCondition baseActivityCondition : activityData.getBaseActivityConditionList()) {
                            if (null != baseActivityCondition) {
                                baseActivityCondition.initValue();
                            }
                        }
                    }
                }
            }
        }
    }

    private Map<Integer, StrongholdActivityData> getActivityDataMap(int activityId) {
        return activityDataMap.get(activityId);
    }

    private void addActivity(ActivityInfo activityInfo, List<UserActivityConditionData> conditionDataList, int type, boolean isNew) {
        if (null != activityInfo) {
            if (!activityDataMap.containsKey(activityInfo.getActivityId())) {
                activityDataMap.put(activityInfo.getActivityId(), new ConcurrentHashMap<>());
            }

            Map<Integer, StrongholdActivityData> dataMap = activityDataMap.get(activityInfo.getActivityId());
            if (dataMap.containsKey(type)) {
                return;
            }
            List<ActivityConditionInfo> conditionInfoList = StrongholdActivityMgr.getActivityConditionInfoList(activityInfo.getActivityId(), type);
            if (null == conditionInfoList) {
                return;
            }

            StrongholdActivityData activityData = new StrongholdActivityData(player, activityInfo, conditionDataList);
            for (ActivityConditionInfo conditionInfo : conditionInfoList) {
                if (activityData.continueAdd(conditionInfo.getType())) {
                    BaseStrongholdActivityCondition baseActivityCondition = BaseStrongholdActivityCondition.createActivityCondition(player, activityData, activityInfo, conditionInfo);
                    if (null != baseActivityCondition) {
                        activityData.addCondition(baseActivityCondition);
                        if (isNew) {
                            UserActivityConditionData userConditionData = ActivityMgr.initUserActivityConditionData(player, conditionInfo);
                            activityData.addUserActivityConditionData(userConditionData);
                            StrongholdActivityMgr.addUserActivityConditionData(getUserId(), userConditionData);
                        }
                    }
                }
            }
            dataMap.put(type, activityData);
            activityData.addToPlayer();
        }
    }

    public void initSystem() {
        syncActivity();
    }


    private int checkGetReward(int activityId, int type) {
        ActivityInfo openActivityInfo = StrongholdActivityMgr.getOpenActivityInfo();
        if (null == openActivityInfo) {
            return GameErrorCode.E_STRONGHOLD_NOT_FOUND;
        }
        Map<Integer, StrongholdActivityData> dataMap = activityDataMap.get(openActivityInfo.getActivityId());
        if (null == dataMap) {
            return GameErrorCode.E_STRONGHOLD_NOT_FOUND;
        }
        StrongholdActivityData activityData = dataMap.get(type);
        if (null == activityData) {
            return GameErrorCode.E_STRONGHOLD_NOT_FOUND;
        }
        if (!StrongholdActivityMgr.activityInRewardPeriod(openActivityInfo)) {
            return GameErrorCode.E_STRONGHOLD_NO_IN_REWARD_TIME;
        }
        if (!StrongholdActivityMgr.activityInCanRewardPeriod()) {
            return GameErrorCode.E_STRONGHOLD_REWARD_SETTLEMENT_TIME;
        }
        UserActivityConditionData conditionData = activityData.getFirstConditionData();
        if (null == conditionData) {
            return GameErrorCode.E_STRONGHOLD_ACTIVITY_NO_JOIN;
        }
        if (conditionData.isGetReward()) {
            return GameErrorCode.E_STRONGHOLD_HAS_GET_REWARD;
        }
        return 0;
    }

    public ActivityRewardResult sendCrossRankReward(int activityId, int conditionId, int type) {
        ActivityRewardResult result = new ActivityRewardResult();
        int ret = checkGetReward(activityId, type);
        if (ret != 0) {
            result.setRet(ret);
            return result;
        }
        ActivityConditionInfo activityConditionInfo = StrongholdActivityMgr.getActivityConditionInfo(activityId, conditionId);
        Map<Integer, StrongholdActivityData> dataMap = activityDataMap.get(activityId);
        StrongholdActivityData activityData = dataMap.get(activityConditionInfo.getType());
        UserActivityConditionData conditionData = activityData.getFirstConditionData();
        String unionUid = player.getUserInfo().getUnionUid();
        //发送请求到跨服获取排名
        CrossActivityProto.CrossActivityGetRewardReqMsg.Builder reqMsg = CrossActivityProto.CrossActivityGetRewardReqMsg.newBuilder();
        reqMsg.setActivityId(activityId);
        reqMsg.setConditionId(conditionData.getConditionId());
        reqMsg.setUnionUid(unionUid);
        player.sendUnionActivityGroupPacket(Protocol.C_CROSS_STRONGHOLD_GET_RANK_REWARD, reqMsg, activityId);
        return result;
    }

    public ActivityRewardResult getCrossRankReward(int activityId, int conditionId, int myRank, int position,String unionId) {
        ActivityRewardResult result = new ActivityRewardResult();
        ActivityInfo activityInfo = StrongholdActivityMgr.getOpenActivityInfo();
        if (activityInfo == null) {
            result.setRet(GameErrorCode.E_ACTIVITY_NO_FOUND);
            return result;
        }
        ActivityConditionInfo activityConditionInfo = StrongholdActivityMgr.getActivityConditionInfo(activityId, conditionId);
        Map<Integer, StrongholdActivityData> dataMap = activityDataMap.get(activityId);
        StrongholdActivityData activityData = dataMap.get(activityConditionInfo.getType());
        UserActivityConditionData conditionData = activityData.getFirstConditionData();
        ActivityConditionInfo conditionInfo = StrongholdActivityMgr.getActivityConditionInfoByRank(activityId, activityConditionInfo.getType(), myRank);
        if (null == conditionInfo) {
            result.setRet(GameErrorCode.E_ACTIVITY_CONDITION_NO_COMPLETE);
            return result;
        }
        if(null == conditionData || conditionData.isGetReward()){
            result.setRet(GameErrorCode.E_ACTIVITY_REWARD_IS_GET);
            return result;
        }
        if (StrongholdActivityMgr.CONDITION_TYPE_WILD_UNION == conditionInfo.getType() || StrongholdActivityMgr.CONDITION_TYPE_ELIMINATE_UNION == conditionInfo.getType()) {
                //根据职位获取奖励
                result.setReward(UnionActivityMgr.getUnionMemberPositionDataReward(position, conditionInfo, player.getUserId()));
                player.getModule(CurrencyModule.class).addCurrency(result.getReward(), eLogMoneyType.Activity, eLogMoneyType.StrongholdActivityUnionRankReward);

        } else {
            player.getModule(CurrencyModule.class).addCurrency(conditionInfo.getReward(), eLogMoneyType.Activity, eLogMoneyType.StrongholdActivityRankReward);
            result.setReward(conditionInfo.getRewardStr());
        }
        conditionData.setGetReward(true);
        onActivityDataChange(activityData);
        activityData.finish(conditionData.getConditionId());

        String rewardStr = result.getReward();
        if (rewardStr != null) {
            Property property = PropertyHelper.parseStringToProperty(rewardStr);
            if (property != null) {
                //记录跨服称号包含的区服id
                property.getGoods().forEach((k, v) -> {
                    if (GoodsMgr.isDecorationGoods(k)) {
                        player.getModule(DecorationModule.class).setServerIds(k, activityInfo.getActivityId(), activityInfo.getServerListStr());
                    }
                });
                player.getModule(BanquetModule.class).getCrossBanquetInvitationReward(rewardStr, activityInfo.getServerListStr());
                CrossUnionMgr.getRewardHonourItem(rewardStr, activityInfo,myRank,unionId,getUserId());
            }
        }

        LogMgr.addLogActivityReward(player.getUserId(), activityId, activityInfo.getType(), activityInfo.getChildType(),
                activityConditionInfo.getConditionId(), myRank, false, result.getReward());
        return result;
    }

    //同步到活动中的condition改名
    public void nickNameChange() {
        ActivityInfo activityInfo = StrongholdActivityMgr.getOpenActivityInfo();
        if (activityInfo != null) {
            Map<Integer, StrongholdActivityData> dataMap = activityDataMap.get(activityInfo.getActivityId());
            if (null != dataMap) {
                StrongholdActivityData activityData = dataMap.get(StrongholdActivityMgr.CONDITION_TYPE_WILD_USER);
                if (null != activityData) {
                    List<UserActivityConditionData> dataList = activityData.getUserActivityConditionDataList();

                }
            }
        }
    }

    public void onActivityDataChange(StrongholdActivityData activityData) {
        CommonActivityProto.CommonActivityDataMsg.Builder dataMsg = StrongholdActivityPb.parseCommonActivityDataMsg(activityData);
        if (dataMsg != null) {
            player.sendPacket(ClientProtocol.U_STRONGHOLD_ACTIVITY_SYNC_DATA, dataMsg);
        }
    }

    public UserActivityConditionData getUserActivityConditionData(int activityId) {
        Map<Integer, StrongholdActivityData> dataMap = activityDataMap.get(activityId);
        if (null != dataMap) {
            StrongholdActivityData activityData = dataMap.get(StrongholdActivityMgr.CONDITION_TYPE_WILD_USER);
            if (null != activityData) {
                return activityData.getFirstConditionData();
            }
        }
        return null;
    }


    @Deprecated
    public ActivityRewardResult getRankReward(int activityId, int type) {
        ActivityRewardResult result = new ActivityRewardResult();
        ActivityInfo openActivityInfo = OreWarActivityMgr.getOpenActivityInfo(activityId);
        if (null == openActivityInfo) {
            result.setRet(GameErrorCode.E_ORE_ACTIVITY_NO_IN_TIME);
            return result;
        }
        Map<Integer, StrongholdActivityData> dataMap = activityDataMap.get(openActivityInfo.getActivityId());
        if (null == dataMap) {
            result.setRet(GameErrorCode.E_ORE_ACTIVITY_NO_IN_TIME);
            return result;
        }
        StrongholdActivityData activityData = dataMap.get(type);
        if (null == activityData) {
            result.setRet(GameErrorCode.E_ORE_ACTIVITY_NO_IN_TIME);
            return result;
        }
        if (!ActivityMgr.activityInRewardPeriod(openActivityInfo)) {
            result.setRet(GameErrorCode.E_ORE_ACTIVITY_NO_IN_REWARD_TIME);
            return result;
        }
        if (!ActivityMgr.activityInCanRewardPeriod(openActivityInfo)) {
            result.setRet(GameErrorCode.E_ORE_ACTIVITY_REWARD_SETTLEMENT_TIME);
            return result;
        }
        UserActivityConditionData conditionData = activityData.getFirstConditionData();
        if (null == conditionData) {
            result.setRet(GameErrorCode.E_ORE_ACTIVITY_NO_JOIN);
            return result;
        }
        if (conditionData.isGetReward()) {
            result.setRet(GameErrorCode.E_ORE_ACTIVITY_HAS_GET_REWARD);
            return result;
        }
        int myRank;
        boolean isMaster = false;
        if (StrongholdActivityMgr.CONDITION_TYPE_WILD_USER == type || StrongholdActivityMgr.CONDITION_TYPE_ELIMINATE_USER == type) {
            myRank = StrongholdActivityRankMgr.getActivityRank(openActivityInfo.getActivityId(), type, player.getUserId());
        } else if (StrongholdActivityMgr.CONDITION_TYPE_WILD_UNION == type || StrongholdActivityMgr.CONDITION_TYPE_ELIMINATE_UNION == type) {
            UnionActivityConditionData unionActivityConditionData = OreWarActivityRankMgr.getUnionActivityConditionData(activityId, player.getUserId());
            if (null == unionActivityConditionData) {
                result.setRet(GameErrorCode.E_ORE_ACTIVITY_NO_JOIN);
                return result;
            }
            myRank = StrongholdActivityRankMgr.getActivityUnionRank(openActivityInfo.getActivityId(), type, unionActivityConditionData.getUnionUid());
            isMaster = (unionActivityConditionData.getUnionBaseInfo().getMasterUserId() == player.getUserId());
        } else {
            result.setRet(GameErrorCode.E_ORE_ACTIVITY_NO_IN_TIME);
            return result;
        }
        ActivityConditionInfo conditionInfo = StrongholdActivityMgr.getActivityConditionInfoByRank(activityId, type, myRank);
        if (conditionInfo != null) {// 添加奖励
            player.getModule(CurrencyModule.class).addCurrency(conditionInfo.getMasterReward(), eLogMoneyType.Activity, eLogMoneyType.OreWarActivityUnionRankReward);
            result.setReward(conditionInfo.getMasterRewardStr());
           /* if (isMaster && OreWarActivityMgr.CONDITION_TYPE_UNION == type) {

            } else {
                if (OreWarActivityMgr.CONDITION_TYPE_UNION == type) {
                    player.getModule(CurrencyModule.class).addCurrency(conditionInfo.getReward(), eLogMoneyType.Activity, eLogMoneyType.OreWarActivityUnionRankReward);
                } else {
                    player.getModule(CurrencyModule.class).addCurrency(conditionInfo.getReward(), eLogMoneyType.Activity, eLogMoneyType.OreWarActivityRankReward);
                }
                result.setReward(conditionInfo.getRewards());
            }*/
        }
        conditionData.setGetReward(true);
        onActivityDataChange(activityData);
        activityData.finish(conditionData.getConditionId());

        LogMgr.addLogOreWarActivityRankReward(player.getUserId(), activityId, type, myRank, result.getReward());
        return result;
    }

}
